import request from "@/utils/request";
import type {
    studentInfoData,
    studentListFormData,
    studentResponseData,
    studentAllResponseData,
    studentListResponseData,
    studentYearResponseData
} from "./type"

enum API {
    STUDENT_ALL_URL = "/manage/student/all", //所有项
    STUDENT_LIST_URL = "/manage/student/list",  //筛选项
    STUDENT_ADD_URL = "/manage/student/add",  //添加项
    STUDENT_GET_ID_URL = "/manage/student/find", //获取id
    STUDENT_UPDATE_URL = "/manage/student/update", //修改
    STUDENT_DELETE_URL = "/manage/student/delete", //删除

    STUDENT_MONTH_DATA_URL = "/manage/student/date", //
}
export const reqStudentAll = () =>
    request.get<any, studentAllResponseData>(API.STUDENT_ALL_URL)
// 读筛选项
export const reqStudentList = (data: studentListFormData) =>
    request.post<any, studentListResponseData>(API.STUDENT_LIST_URL, data)
// 添加
export const reqStudentAdd = (data: studentInfoData) =>
    request.post<any, studentResponseData>(API.STUDENT_ADD_URL, data)

//ID获取
export const reqStudentById = (_id: string) =>
    request.get<any, studentResponseData>(API.STUDENT_GET_ID_URL + `?_id=${_id}`)

// 修改
export const reqStudentUpdata = (data: studentInfoData) =>
    request.post<any, studentResponseData>(API.STUDENT_UPDATE_URL, data)
// 删除
export const reqStudentDelete = (studentId: string) =>
    request.post<any, studentResponseData>(API.STUDENT_DELETE_URL, { studentId })

export const reqStudentForYear = (year: number) =>
    request.post<any, studentYearResponseData>(API.STUDENT_MONTH_DATA_URL, { year })